#!encoding:utf-8
from lxml import etree
import os
import urllib



import sys

# make sure the string pass to lxml must be unicode
page=os.popen('w3m -dump_source '+sys.argv[1]).read()
selector=etree.HTML(page)
selector=selector.xpath(sys.argv[2])
if sys.argv[2].endswith('text()'):
    for x in selector:
         print x
else:
    for xx in [x.xpath('string(.)') for x in selector]:
        print xx
    
